package com.ae.shield.common.events;

import com.ae.shield.ModLib;
import com.ae.shield.common.config.Config;
import com.ae.shield.common.world.gen.feature.OreFeature;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = ModLib.MOD_ID)
public class WorldEvent {
    @SubscribeEvent(priority = EventPriority.HIGH)
    public static void OreGenerator(BiomeLoadingEvent event) {
        BiomeGenerationSettingsBuilder builder = event.getGeneration();
        Biome.Category biome = event.getCategory();
        if (biome == Biome.Category.THEEND) {
            //暂时没有需要生成的内容，但以后可能会有，
        } else if (biome == Biome.Category.NETHER) {
            //暂时没有需要生成的内容，但以后可能会有，
        } else {
            if (Config.ORE_GENERATE.get()) {
                if (Config.ORE_TIN.get())
                    builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, OreFeature.ORES_TIN);
                if (Config.ORE_LEAD.get())
                    builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, OreFeature.ORES_LEAD);
                if (Config.ORE_SILVER.get())
                    builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, OreFeature.ORES_SILVER);
                if (Config.ORE_ALUMINUM.get())
                    builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, OreFeature.ORES_ALUMINUM);
                if (Config.ORE_MANGANESE.get())
                    builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, OreFeature.ORES_MANGANESE);
                if (Config.ORE_TANTALUM.get())
                    builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, OreFeature.ORES_TANTALUM);
            }
        }
    }
}
